<!DOCTYPE html>
<!-- saved from url=(0060)http://deors.wordpress.com/2011/10/08/annotation-processors/ -->
<html lang="en"><!--<![endif]--><!--
	generated in 0.312 seconds
	55016 bytes batcached for 300 seconds
--><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>Code Generation using Annotation Processors in the Java language – part 2: Annotation Processors | dr. macphail's trance</title>
<link rel="profile" href="http://gmpg.org/xfn/11">
<link rel="stylesheet" type="text/css" media="all" href="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/style.css">
<link rel="pingback" href="http://deors.wordpress.com/xmlrpc.php">
<!--[if lt IE 9]>
<script src="http://s2.wp.com/wp-content/themes/pub/twentyeleven/js/html5.js?m=1315596887g" type="text/javascript"></script>
<![endif]-->
<link rel="alternate" type="application/rss+xml" title="dr. macphail&#39;s trance » Feed" href="http://deors.wordpress.com/feed/">
<link rel="alternate" type="application/rss+xml" title="dr. macphail&#39;s trance » Comments Feed" href="http://deors.wordpress.com/comments/feed/">
<link rel="alternate" type="application/rss+xml" title="dr. macphail&#39;s trance » Code Generation using Annotation Processors in the Java language – part 2: Annotation Processors Comments Feed" href="http://deors.wordpress.com/2011/10/08/annotation-processors/feed/">
<script src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/quant.js" async="" type="text/javascript"></script><script type="text/javascript">
/* <![CDATA[ */
function addLoadEvent(func){var oldonload=window.onload;if(typeof window.onload!='function'){window.onload=func;}else{window.onload=function(){oldonload();func();}}}
/* ]]> */
</script>
<link rel="stylesheet" id="all-css-0" href="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/saved_resource" type="text/css" media="all">
<script type="text/javascript">
/* <![CDATA[ */
var LoggedOutFollow = {"invalid_email":"Your subscription did not succeed, please try again with a valid email address."};
/* ]]> */
</script>
<script type="text/javascript" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/saved_resource(1)"></script>
<link rel="stylesheet" id="all-css-0" href="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/style(1).css" type="text/css" media="all">
<!--[if lt IE 8]>
<link rel='stylesheet' id='highlander-comments-ie7-css'  href='http://s2.wp.com/wp-content/mu-plugins/highlander-comments/style-ie7.css?m=1351637563g&#038;ver=20110606' type='text/css' media='all' />
<![endif]-->
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://deors.wordpress.com/xmlrpc.php?rsd">
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://deors.wordpress.com/wp-includes/wlwmanifest.xml"> 
<link rel="prev" title="Integrate HtmlUnit Based Tests with Apache Maven and Cargo" href="http://deors.wordpress.com/2011/09/30/maven-htmlunit/">
<link rel="next" title="Measure Code Coverage of HtmlUnit Based Tests with Sonar and JaCoCo" href="http://deors.wordpress.com/2011/10/20/htmlunit-sonar-jacoco/">
<meta name="generator" content="WordPress.com">
<link rel="canonical" href="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance.htm">
<link rel="shortlink" href="http://wp.me/p1timC-1n">
<link rel="alternate" type="application/json+oembed" href="http://public-api.wordpress.com/oembed/1.0/?format=json&url=http%3A%2F%2Fdeors.wordpress.com%2F2011%2F10%2F08%2Fannotation-processors%2F&for=wpcom-auto-discovery"><link rel="alternate" type="application/xml+oembed" href="http://public-api.wordpress.com/oembed/1.0/?format=xml&url=http%3A%2F%2Fdeors.wordpress.com%2F2011%2F10%2F08%2Fannotation-processors%2F&for=wpcom-auto-discovery">
<!-- Jetpack Open Graph Tags -->
<meta property="og:type" content="article">
<meta property="og:title" content="Code Generation using Annotation Processors in the Java language – part 2: Annotation Processors">
<meta property="og:url" content="http://deors.wordpress.com/2011/10/08/annotation-processors/">
<meta property="og:description" content="This post is the second part in my series about Code Generation using Annotation Processors in the Java language. In part 1 (read it here) we introduced what Annotations are in the Java language an...">
<meta property="og:site_name" content="dr. macphail&#39;s trance">
<meta property="og:image" content="http://i2.wp.com/deors.files.wordpress.com/2011/10/picture11.png?fit=400%2C400">
<meta property="og:image" content="http://i1.wp.com/deors.files.wordpress.com/2011/10/picture10.png?fit=400%2C400">
<meta property="og:image" content="http://i0.wp.com/deors.files.wordpress.com/2011/10/picture9.png?fit=400%2C400">
<meta property="og:image" content="http://i2.wp.com/deors.files.wordpress.com/2011/10/picture8.png?fit=400%2C400">
<meta property="og:image" content="http://i1.wp.com/deors.files.wordpress.com/2011/10/picture7.png?fit=400%2C400">
<meta name="twitter:image" content="http://i2.wp.com/deors.files.wordpress.com/2011/10/picture11.png">
<meta name="twitter:card" content="summary">
<meta property="fb:app_id" content="249643311490">
<link rel="shortcut icon" type="image/x-icon" href="http://0.gravatar.com/blavatar/0895510d759bcf7a89fb6795f93007b7?s=16" sizes="16x16">
<link rel="icon" type="image/x-icon" href="http://0.gravatar.com/blavatar/0895510d759bcf7a89fb6795f93007b7?s=16" sizes="16x16">
<link rel="apple-touch-icon-precomposed" href="http://1.gravatar.com/blavatar/d531b0707db7a2fd8494cc296005ecb3?s=114">
<link rel="openid.server" href="http://deors.wordpress.com/?openidserver=1">
<link rel="openid.delegate" href="http://deors.wordpress.com/">
<link rel="search" type="application/opensearchdescription+xml" href="http://deors.wordpress.com/osd.xml" title="dr. macphail&#39;s trance">
<link rel="search" type="application/opensearchdescription+xml" href="http://wordpress.com/opensearch.xml" title="WordPress.com">
		<style>
		/* <![CDATA[ */
		/* Block: reblog */
		
		.reblog-from img                   { margin: 0 10px 0 0; vertical-align: middle; padding: 0; border: 0; }
		.reblogger-note img.avatar         { float: left; padding: 0; border: 0; }
		.reblogger-note-content            { margin: 0 0 20px; }
		.reblog-post .wpcom-enhanced-excerpt-content { border-left: 3px solid #eee; padding-left: 15px; }
		.reblog-post ul.thumb-list         { display: block; list-style: none; margin: 2px 0; padding: 0; clear: both; }
		.reblog-post ul.thumb-list li      { display: inline; margin: 0; padding: 0 1px; border: 0; }
		.reblog-post ul.thumb-list li a    { margin: 0; padding: 0; border: 0; }
		.reblog-post ul.thumb-list li img  { margin: 0; padding: 0; border: 0; }
		
		.reblog-post .wpcom-enhanced-excerpt { clear: both; }
		
		.reblog-post .wpcom-enhanced-excerpt address,
		.reblog-post .wpcom-enhanced-excerpt li,
		.reblog-post .wpcom-enhanced-excerpt h1,
		.reblog-post .wpcom-enhanced-excerpt h2,
		.reblog-post .wpcom-enhanced-excerpt h3,
		.reblog-post .wpcom-enhanced-excerpt h4,
		.reblog-post .wpcom-enhanced-excerpt h5,
		.reblog-post .wpcom-enhanced-excerpt h6,
		.reblog-post .wpcom-enhanced-excerpt p { font-size: 100% !important; }
		
		.reblog-post .wpcom-enhanced-excerpt blockquote,
		.reblog-post .wpcom-enhanced-excerpt pre,
		.reblog-post .wpcom-enhanced-excerpt code,
		.reblog-post .wpcom-enhanced-excerpt q { font-size: 98% !important; }
		

		/* ]]> */		
		</style>
		<meta name="application-name" content="dr. macphail&#39;s trance"><meta name="msapplication-window" content="width=device-width;height=device-height"><meta name="msapplication-tooltip" content="the cake is a lie"><meta name="msapplication-task" content="name=Subscribe;action-uri=http://deors.wordpress.com/feed/;icon-uri=http://0.gravatar.com/blavatar/0895510d759bcf7a89fb6795f93007b7?s=16"><meta name="msapplication-task" content="name=Sign up for a free blog;action-uri=http://wordpress.com/signup/;icon-uri=http://s2.wp.com/i/favicon.ico"><meta name="msapplication-task" content="name=WordPress.com Support;action-uri=http://support.wordpress.com/;icon-uri=http://s2.wp.com/i/favicon.ico"><meta name="msapplication-task" content="name=WordPress.com Forums;action-uri=http://forums.wordpress.com/;icon-uri=http://s2.wp.com/i/favicon.ico"><meta name="title" content="Code Generation using Annotation Processors in the Java language – part 2: Annotation Processors | dr. macphail&#39;s trance on WordPress.com">
<meta name="description" content="This post is the second part in my series about Code Generation using Annotation Processors in the Java language. In part 1 (read it here) we introduced what Annotations are in the Java language and some of their common uses. … Continue reading →">

<script type="text/javascript" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/google_service.js">
</script>
<script type="text/javascript">
GS_googleAddAdSenseService("ca-pub-3443918307802676");
GS_googleEnableAllServices();
</script><script src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/google_ads.js"></script>
<script type="text/javascript">
GA_googleAddSlot("ca-pub-3443918307802676", "wpcom_below_post_adsafe");
</script>
<script type="text/javascript">
GA_googleFetchAds();
</script>
<script type="text/javascript"> 
	window.google_analytics_uacct = "UA-52447-2"; 
</script>

<script type="text/javascript">
	var _gaq = _gaq || [];
	_gaq.push(['_setAccount', 'UA-52447-2']);
	_gaq.push(['_setDomainName', 'wordpress.com']);
	_gaq.push(['_initData']);
	_gaq.push(['_trackPageview']);

	(function() {
		var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
	})();
</script><script type="text/javascript" async="" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/ga.js"></script>
<link rel="stylesheet" type="text/css" id="gravatar-card-css" href="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/hovercard.css"><link rel="stylesheet" type="text/css" id="gravatar-card-services-css" href="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/services.css"></head>

<body class="single single-post postid-85 single-format-standard single-author singular two-column right-sidebar highlander-enabled highlander-light">
<div id="page" class="hfeed">
	<header id="branding" role="banner">
			<hgroup>
				<h1 id="site-title"><span><a href="http://deors.wordpress.com/" title="dr. macphail&#39;s trance" rel="home">dr. macphail's trance</a></span></h1>
				<h2 id="site-description">the cake is a lie</h2>
			</hgroup>

						<a href="http://deors.wordpress.com/">
									<img src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/blog-header-1.jpg" width="1000" height="288" alt="">
							</a>
			
								<form method="get" id="searchform" action="http://deors.wordpress.com/">
		<label for="s" class="assistive-text">Search</label>
		<input type="text" class="field" name="s" id="s" placeholder="Search">
		<input type="submit" class="submit" name="submit" id="searchsubmit" value="Search">
	</form>
			
			<nav id="access" role="navigation">
				<h3 class="assistive-text">Main menu</h3>
								<div class="skip-link"><a class="assistive-text" href="http://deors.wordpress.com/2011/10/08/annotation-processors/#content" title="Skip to primary content">Skip to primary content</a></div>
				<div class="skip-link"><a class="assistive-text" href="http://deors.wordpress.com/2011/10/08/annotation-processors/#secondary" title="Skip to secondary content">Skip to secondary content</a></div>
								<div class="menu"><ul><li><a href="http://deors.wordpress.com/" title="Home">Home</a></li><li class="page_item page-item-2"><a href="http://deors.wordpress.com/about/">about dr. macphail’s&nbsp;trance</a></li></ul></div>
			</nav><!-- #access -->
	</header><!-- #branding -->


	<div id="main">

		<div id="primary">
			<div id="content" role="main">

				
					<nav id="nav-single">
						<h3 class="assistive-text">Post navigation</h3>
						<span class="nav-previous"><a href="http://deors.wordpress.com/2011/09/30/maven-htmlunit/" rel="prev"><span class="meta-nav">←</span> Previous</a></span>
						<span class="nav-next"><a href="http://deors.wordpress.com/2011/10/20/htmlunit-sonar-jacoco/" rel="next">Next <span class="meta-nav">→</span></a></span>
					</nav><!-- #nav-single -->

					
<article id="post-85" class="post-85 post type-post status-publish format-standard hentry category-automation category-java tag-annotation-processors tag-annotations tag-eclipse tag-maven">
	<header class="entry-header">
		<h1 class="entry-title">Code Generation using Annotation Processors in the Java language – part 2: Annotation&nbsp;Processors</h1>

				<div class="entry-meta">
			<span class="sep">Posted on </span><a href="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance.htm" title="22:43" rel="bookmark"><time class="entry-date" datetime="2011-10-08T22:43:52+00:00" pubdate="">08/10/2011</time></a><span class="by-author"> <span class="sep"> by </span> <span class="author vcard"><a class="url fn n" href="http://deors.wordpress.com/author/deors/" title="View all posts by deors" rel="author">deors</a></span></span>		</div><!-- .entry-meta -->
			</header><!-- .entry-header -->

	<div class="entry-content">
		<p>This post is the second part in my series about Code Generation using Annotation Processors in the Java language. In part 1 (read it <a href="http://deors.wordpress.com/2011/09/26/annotation-types/">here</a>) we introduced what Annotations are in the Java language and some of their common uses.</p>
<p>Now in part 2 we are going to introduce Annotation Processors, how to build them and how to run them.</p>
<h2>Code Generation using Annotation Processors in the Java language – part 2: Annotation Processors</h2>
<p>Annotations are great, sure. You can set any kind of metadata or configuration with them, with a well defined syntax and different types to use.</p>
<p>From what we have seen until now, annotations have advantages compared with Javadocs but not enough to justify their inclusion into the language. Therefore, is it possible to interact with annotations and get the most from them? Sure it is:</p>
<ul>
<li>At runtime, annotations with runtime retention policy are accessible through reflection. The methods getAnnotation() and getAnnotations() in Class class will do the magic (1).</li>
<li>At compile time, Annotation Processors, a specialized type of classes, will handle the different annotations found in code being compiled.</li>
</ul>
<h4><span id="more-85"></span>The Annotation Processor API</h4>
<p>When Annotations were first introduced in Java 5, the Annotation Processor API was not mature or standardized. A standalone tool named apt, the Annotation Processor Tool, was needed to process annotations, and the Mirror API, used by apt to write custom processors, was distributed in com.sun.mirror packages.</p>
<p>Starting with Java 6, Annotation Processors were standardized through JSR 269 (2), incorporated into the standard libraries and the tool apt seamlessly integrated with the Java Compiler Tool, javac.</p>
<p>Although we will only describe in detail the new Annotation Processor API from Java 6, you can find more information about apt and the Mirror API in JDK 5 documentation <a href="http://download.oracle.com/javase/1.5.0/docs/guide/apt/">here</a> and <a href="http://download.oracle.com/javase/1.5.0/docs/guide/apt/mirror/overview-summary.html">here</a> and a fine example in <a href="http://www.javalobby.org/java/forums/t17876.html">this article</a>.</p>
<p>An annotation processor is no more than a class that implements javax.annotation.processing.Processor interface and adheres to the given contract. For our convenience an abstract implementation with common functionality for custom processors is provided in the class javax.annotation.processing.AbstractProcessor.</p>
<p>The custom processor may use three annotations to configure itself:</p>
<ul>
<li>javax.annotation.processing.SupportedAnnotationTypes: This annotation is used to register the annotations that the processor supports. Valid values are fully qualified names of annotation types – wildcards are allowed.</li>
<li>javax.annotation.processing.SupportedSourceVersion: This annotation is used to register the source version that the processor supports.</li>
<li>javax.annotation.processing.SupportedOptions: This annotation is used to register allowed custom options that may be passed through the command line.</li>
</ul>
<p>Finally, we provide our implementation of the process() method.</p>
<h4>Writing our first Annotation Processor</h4>
<p>Let’s start writing our first Annotation Processor. Following the general notes on previous section, we build the following class to process the Complexity annotation introduced in part 1:</p>
<pre>    package sdc.assets.annotations.processors;

    import …

    @SupportedAnnotationTypes("sdc.assets.annotations.Complexity")
    @SupportedSourceVersion(SourceVersion.RELEASE_6)
    public class ComplexityProcessor extends AbstractProcessor {

    &nbsp;&nbsp;&nbsp; public ComplexityProcessor() {
 &nbsp;&nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; super();
 &nbsp;&nbsp;&nbsp;    }

    &nbsp;&nbsp;&nbsp; @Override
 &nbsp;&nbsp;   &nbsp; public boolean process(Set&lt;? extends TypeElement&gt; annotations,
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RoundEnvironment roundEnv) {
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return true;
 &nbsp;&nbsp;   &nbsp; }
    }</pre>
<p>This incomplete class, although does nothing when called, is registered to support annotations of type sdc.assets.annotations.Complexity. Therefore, each time the Java Compiler founds a class annotated with that type will execute the processor, given that the process is available in the classpath (we will see more about that later).</p>
<p>To interact with the annotated class, the process() method receives two parameters:</p>
<div>
<ul>
<li>A set of java.lang.model.TypeElement objects: Annotation processing is done in one or several rounds. In each round the processors are called and they receive in this set the types of the annotations being processed in the current round.</li>
<li>A javax.annotation.processing.RoundEnvironment objects: This object gives access to the annotated source elements being processed in the current and previous round.</li>
</ul>
</div>
<div>
<p>In addition to the two parameters, a ProcessingEnvironment object is available in the processingEnv instance variable. This object gives access to the log and also to a few utilities; some will be discussed later.</p>
<p>Using the RoundEnvironment object and the reflective methods of the Element interface, we can write a simple implementation for an annotation processor that just logs the complexity of each annotated element found:</p>
<pre>    for (Element elem : roundEnv.getElementsAnnotatedWith(Complexity.class)) {
    &nbsp;&nbsp;&nbsp; Complexity complexity = elem.getAnnotation(Complexity.class);
 &nbsp;&nbsp;&nbsp;    String message = "annotation found in " + elem.getSimpleName()
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + " with complexity " + complexity.value();
    &nbsp;&nbsp;&nbsp; processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, message);
    }
    return true; // no further processing of this annotation type</pre>
</div>
<h4>Packaging and registering the Annotation Processor</h4>
<p>The final step needed to finish our custom Annotation Processor, is to package and register it so the Java Compiler or other tools can find it.</p>
<p>The easiest way to register the processor is to leverage the standard Java services mechanism:</p>
<div>
<ul>
<li>Package your Annotation Processor in a Jar file.</li>
<li>Include in the Jar file a directory META-INF/services.</li>
<li>Include in the directory a file named javax.annotation.processing.Processor.</li>
<li>Write in the file the fully qualified names of the processors contained in the Jar file, one per line.</li>
</ul>
</div>
<p>The Java Compiler and other tools will search for this file in all provided classpath elements and make use of the registered processors.</p>
<p>For our example, the folder structure and file content will be the following:</p>
<p><a href="http://deors.files.wordpress.com/2011/10/picture1.png"><img class="alignnone size-full wp-image-87" title="Picture1" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/picture1.png" alt=""></a></p>
<p><a href="http://deors.files.wordpress.com/2011/10/picture2.png"><img class="alignnone size-full wp-image-88" title="Picture2" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/picture2.png" alt=""></a></p>
<p>Once packaged, we are ready to start using it.</p>
<h4>Running Processors with javac</h4>
<p>Imagine that you have a Java project that is making use of some custom annotations and that have available annotation processors. In Java 5, compilation and processing were two different steps (and two different tools), but with Java 6 both tasks are integrated in the Java Compiler tool, javac.</p>
<p>If you add to javac’s classpath the annotation processors and they are registered using the service mechanism as described before, they will be executed by javac.</p>
<p>Following our example, this command would compile and process a Java source file that is using the Complexity annotation:</p>
<pre>&nbsp;&nbsp;&nbsp; &gt;javac -cp sdc.assets.annotations-1.0-SNAPSHOT.jar;
&nbsp;&nbsp;&nbsp;&nbsp; sdc.assets.annotations.processors-1.0-SNAPSHOT.jar
&nbsp;&nbsp;&nbsp;&nbsp; SimpleAnnotationsTest.java</pre>
<p>The contents of the Java class used for the test is:</p>
<pre>    package sdc.startupassets.annotations.base.client;

    import ...

    @Complexity(ComplexityLevel.VERY_SIMPLE)
    public class SimpleAnnotationsTest {

        public SimpleAnnotationsTest() {
            super();
        }

        @Complexity() // this annotation type applies also to methods
                      // the default value 'ComplexityLevel.MEDIUM' is assumed
        public void theMethod() {
            System.out.println("console output");
        }
    }</pre>
<p>And the output, when we execute the javac command, is, as expected:</p>
<p><a href="http://deors.files.wordpress.com/2011/10/picture3.png"><img class="alignnone size-full wp-image-90" title="Picture3" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/picture3.png" alt=""></a></p>
<p>Although the default javac behavior will usually be fine, there are some options that will help us to run annotation processors in any possible scenario:</p>
<div>
<ul>
<li>-Akey[=value] : Used to pass options to the processors. Only those options registered with the SupportedOptions annotation are passed to a processor.</li>
<li>-proc:{none|only} : By the default, javac will run annotation processors and compile all sources. Using proc:none option, no annotation processing is done – useful when you are building annotation processors themselves. Using proc:only option, only annotation processing is done – useful when you are running validations, as quality tools or standards checkers, inside annotation processors.</li>
<li>-processorpath path : Used to specify where the annotation processors and their dependencies can be found. It is optional, and if not present the regular classpath is searched. It is useful to keep a clear differentiation between project dependencies and processors dependencies (that do not need to be carried on for runtime).</li>
<li>-s dir : Used to specify where the generated sources will be placed. This directory must exists before javac command is executed although the sub-directory structure that matches package hierarchy of generated sources is created if needed.</li>
<li>-processor class1[,class2,class3…] : Used to specify the fully qualified names of the annotation processors that will be executed. When this option is present, the default discovery process, based on the services mechanism as discussed before, is bypassed. This is useful when we want to run only a limited set of processor although there are more registered in the classpath.</li>
</ul>
</div>
<h4>Running Processors with Eclipse</h4>
<p>The Eclipse IDE and other major IDE’s supports annotation processors and integrate them with the regular building process.</p>
<p>In Eclipse IDE, when you access the properties dialog on a Java project, you can find, inside Java Compiler group, a page of options named Annotation Processing.</p>
<p><a href="http://deors.files.wordpress.com/2011/10/picture4.png"><img class="alignnone size-full wp-image-91" title="Picture4" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/picture4.png" alt=""></a></p>
<p>In the Annotation Processing options page, activate Enable Annotation Processing (it is not activated by default). Processor options can be passed by using the table in this options page.</p>
<p>Also, select the processors to be executed in the Factory Path options page.</p>
<p><a href="http://deors.files.wordpress.com/2011/10/picture51.png"><img class="alignnone size-full wp-image-93" title="Picture5" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/picture51.png" alt=""></a></p>
<p>Once configured, each time a build action is triggered in the project, the annotation processors will be executed.</p>
<h4>Running Processors with Maven</h4>
<p>Annotation processors can also be executed integrated in Apache Maven builds.</p>
<p>The level of automation that we can achieve will allow us to seamlessly integrate all types of tasks with the building process. Validating standards or generating code do not need to be a separate process in a project lifecycle anymore. It also allows seamless integration with Continuous Integration engines.</p>
<p>Although there are other ways to integrate annotation processors with Maven builds, we recommend the approach described here. The approach discussed is based on the same Mojo (Maven plug-in) that take care of compilation tasks. Actually, as it using the Java Compiler tool, the approach produces the most standard approach that we know of.</p>
<p>Integration with Maven will require that both our Annotations and our Annotation Processors are available as Maven artifacts.</p>
<p>We recommend to keep them in different artifacts, as Annotation Processors will not be needed to be accessible to other client projects, so we reduce the number of dependencies across projects.</p>
<p>With this approach, we will setup three different projects, corresponding each one to a Maven artifact:</p>
<div>
<ul>
<li>The Annotation artifact. It contains only the Annotation Types.</li>
<li>The Annotation Processor artifact. It contains the Annotation Processors. It will depend on the Annotation artifact plus the dependencies needed by the processors themselves to do their tasks. The compiler plugin will need to be configured as proc:none so annotation processing is not performed when building this artifact.</li>
<li>The client project. It contains the client code. It will depend on the two previous artifacts.</li>
</ul>
</div>
<p>This is an example of the directory structure and POM for the Annotation artifact:</p>
<p><a href="http://deors.files.wordpress.com/2011/10/picture6.png"><img class="alignnone size-full wp-image-94" title="Picture6" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/picture6.png" alt=""></a></p>
<p><a href="http://deors.files.wordpress.com/2011/10/picture7.png"><img class="alignnone size-full wp-image-95" title="Picture7" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/picture7.png" alt=""></a></p>
<p>Note the Maven compiler plug-in version used to build this artifact.</p>
<p>This is an example of the directory structure and POM for the Annotation Processor artifact:</p>
<p><a href="http://deors.files.wordpress.com/2011/10/picture8.png"><img class="alignnone size-full wp-image-97" title="Picture8" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/picture8.png" alt=""></a></p>
<p><a href="http://deors.files.wordpress.com/2011/10/picture9.png"><img class="alignnone size-full wp-image-98" title="Picture9" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/picture9.png" alt=""></a></p>
<p>Note the services directory for packaging the processor, the Maven compiler plug-in version used, the proc:none option to prevent running processors when building this one, and the dependency on the artifact that contains the Annotation types.</p>
<p>And finally, this is an example of the directory structure and POM for the client artifact:</p>
<p><a href="http://deors.files.wordpress.com/2011/10/picture10.png"><img class="alignnone size-full wp-image-100" title="Picture10" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/picture10.png" alt=""></a></p>
<p><a href="http://deors.files.wordpress.com/2011/10/picture11.png"><img class="alignnone size-full wp-image-101" title="Picture11" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/picture11.png" alt=""></a></p>
<p>Note the two dependencies here to the Annotation types artifact and to the processor artifact.</p>
<p>Once done, each time the compile goal is executed in a Maven build, the processor will be executed as expected.</p>
<p>—</p>
<p>The series will continue on part 3:&nbsp;Generating source code. Read it <a href="http://deors.wordpress.com/2011/10/31/annotation-generators/">here</a>.</p>
<p>—</p>
<p>(1)&nbsp;Visit Class API documentation for more information <a href="http://download.oracle.com/javase/6/docs/api/java/lang/Class.html">here</a>.</p>
<p>(2) The JSR 269, Pluggable Annotation Processor API, can be browsed online <a href="http://jcp.org/en/jsr/detail?id=269">here</a>.</p>

<div class="wpadvert" style="position: relative; width:300px; text-align: center; padding: 0; margin: 10px auto; overflow: hidden;">
<a style="position: absolute; text-align: left; display: block; font: 9px/1 sans-serif; text-decoration: underline;" href="http://en.wordpress.com/about-these-ads/" rel="nofollow">About these ads</a>
<script type="text/javascript">
GA_googleAddAttr("AdOpt", "1");
GA_googleAddAttr("Origin", "other");
GA_googleAddAttr("LangId", "1");
GA_googleAddAttr("Domain", "deors.wordpress.com");
GA_googleAddAttr("BlogId", "21758442");
GA_googleAddAttr("AdSafe", "1");
GA_googleAddAttr("Autotag", "technology");
GA_googleAddAttr("Tag", "automation");
GA_googleAddAttr("Tag", "java");
GA_googleAddAttr("Tag", "annotation-processors");
GA_googleAddAttr("Tag", "annotations");
GA_googleAddAttr("Tag", "eclipse");
GA_googleAddAttr("Tag", "maven");
GA_googleAddAttr("theme_bg", "ffffff"); 
GA_googleAddAttr("theme_border", "dddddd"); 
GA_googleAddAttr("theme_text", "333333"); 
GA_googleAddAttr("theme_link", "1bafe0"); 
GA_googleAddAttr("theme_url", "1bafe0"); 
GA_googleAddAdSensePageAttr("google_page_url", "http://deors.wordpress.com/2011/10/08/annotation-processors/");
GA_googleFillSlot("wpcom_below_post_adsafe");
</script><script src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/ads"></script>
</div>
<style type="text/css">
div.wpadvert>div { margin-top: 1em; }
</style>
<script type="text/javascript">
jQuery( window ).load( function() {
    if ( jQuery(".wpadvert script[src*='shareth.ru']").length > 0 || jQuery(".wpadvert .sharethrough-placement").length > 0 ) {
        jQuery( '.wpadvert' ).css( 'width', '400px' );
    }
setTimeout(function(){if(typeof GS_googleAddAdSenseService !== 'function'){new Image().src=document.location.protocol+"//stats.wordpress.com/g.gif?v=wpcom-no-pv&x_noads=adblock&baba="+Math.random()}},100);
} );
</script>
<div id="jp-post-flair" class="sharedaddy sd-like-enabled"><div class="wpl-likebox sd-block sd-like"><h3 class="sd-title">Like this:</h3><div class="sd-content"><div id="like-85" class="wpl-button "><a href="http://deors.wordpress.com/2011/10/08/annotation-processors/?like=1&_wpnonce=ff26369b27" title="I like this." class="like needs-login sd-button" rel="nofollow"><span>Like</span></a></div><div class="wpl-count sd-like-count">One blogger likes this.</div><ul class="wpl-avatars sd-like-gravatars"><li><a href="http://gravatar.com/ashokjha" class="wpl-liker" rel="nofollow"><img src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/d224747f067e58617092641bee8ed349" class="avatar avatar-30 grav-hashed" alt="ashokjha" width="30" height="30" id="grav-d224747f067e58617092641bee8ed349-0"></a></li></ul></div></div></div>			</div><!-- .entry-content -->

	<footer class="entry-meta">
		This entry was posted in <a href="http://deors.wordpress.com/category/automation/" title="View all posts in Automation" rel="category tag">Automation</a>, <a href="http://deors.wordpress.com/category/java/" title="View all posts in Java" rel="category tag">Java</a> and tagged <a href="http://deors.wordpress.com/tag/annotation-processors/" rel="tag">Annotation Processors</a>, <a href="http://deors.wordpress.com/tag/annotations/" rel="tag">Annotations</a>, <a href="http://deors.wordpress.com/tag/eclipse/" rel="tag">Eclipse</a>, <a href="http://deors.wordpress.com/tag/maven/" rel="tag">Maven</a> by <a href="http://deors.wordpress.com/author/deors/">deors</a>. Bookmark the <a href="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance.htm" title="Permalink to Code Generation using Annotation Processors in the Java language – part 2: Annotation Processors" rel="bookmark">permalink</a>.		
			</footer><!-- .entry-meta -->
</article><!-- #post-85 -->

						<div id="comments">
	
	
			<h2 id="comments-title">
			3 thoughts on “<span>Code Generation using Annotation Processors in the Java language – part 2: Annotation&nbsp;Processors</span>”		</h2>

		
		<ol class="commentlist">
				<li class="post pingback">
		<p>Pingback: <a href="http://deors.wordpress.com/2011/09/26/annotation-types/" rel="external nofollow" class="url">Code Generation using Annotation Processors in the Java language – part 1: Annotation Types « dr. macphail's trance</a></p>
	</li>
	<li class="post pingback">
		<p>Pingback: <a href="http://deors.wordpress.com/2011/10/31/annotation-generators/" rel="external nofollow" class="url">Code Generation using Annotation Processors in the Java language – part 3: Generating Source Code « dr. macphail's trance</a></p>
	</li>
	<li class="comment byuser comment-author-jbravomontero even thread-even depth-1 highlander-comment" id="li-comment-308">
		<article id="comment-308" class="comment">
			<footer class="comment-meta">
				<div class="comment-author vcard">
					<img alt="" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/e0a9e6bbe2424900880e24e19dab9a7f" class="avatar avatar-68 grav-hashed grav-hijack" height="68" width="68" id="grav-e0a9e6bbe2424900880e24e19dab9a7f-0"><span class="fn"><a href="http://jbravomontero.wordpress.com/" rel="external nofollow" class="url">jbravomontero</a></span> on <a href="http://deors.wordpress.com/2011/10/08/annotation-processors/#comment-308"><time pubdate="" datetime="2012-09-14T17:33:33+00:00">14/09/2012 at 17:33</time></a> <span class="says">said:</span>
									</div><!-- .comment-author .vcard -->

				
			</footer>

			<div class="comment-content"><p>Reblogged this on <a href="http://jbravomontero.wordpress.com/2012/09/14/245/" rel="nofollow">Jbravomontero's Blog</a>.</p>
</div>

			<div class="reply">
				<a class="comment-reply-link" href="http://deors.wordpress.com/2011/10/08/annotation-processors/?replytocom=308#respond" onclick="return addComment.moveForm(&quot;comment-308&quot;, &quot;308&quot;, &quot;respond&quot;, &quot;85&quot;)">Reply <span>↓</span></a>			</div><!-- .reply -->
		</article><!-- #comment-## -->

	</li>
		</ol>

		
	
	
									<div id="respond" class="js">
				<h3 id="reply-title">Leave a Reply <small><a rel="nofollow" id="cancel-comment-reply-link" href="http://deors.wordpress.com/2011/10/08/annotation-processors/#respond" style="display:none;">Cancel reply</a></small></h3>
									<form action="http://deors.wordpress.com/wp-comments-post.php" method="post" id="commentform">
																										


												
<input type="hidden" name="hc_post_as" id="hc_post_as" value="guest">

<div class="comment-form-field comment-textarea">
	
	<div id="comment-form-comment"><textarea placeholder="Enter your comment here..." style="height: 42px; resize: none; overflow-y: hidden; position: absolute; top: 0px; left: -9999px; width: 587px; line-height: 22px; text-decoration: initial; letter-spacing: 0px;" tabindex="-1"></textarea><textarea id="comment" name="comment" placeholder="Enter your comment here..." style="height: 42px; resize: none; overflow-y: hidden;"></textarea></div>
</div>

<div id="comment-form-identity" style="display: none;">

	<div id="comment-form-nascar">
		<p>Fill in your details below or click an icon to log in:</p>
		<ul>
			<li class="selected" style="display:none;">
				<a href="http://deors.wordpress.com/2011/10/08/annotation-processors/#comment-form-guest" id="postas-guest" title="Guest">
					<span></span>
				</a>
			</li>
			<li>
				<a href="http://deors.wordpress.com/2011/10/08/annotation-processors/#comment-form-load-service:WordPress.com" id="postas-wordpress" title="WordPress.com">
					<span></span>
				</a>
			</li>
			<li>
				<a href="http://deors.wordpress.com/2011/10/08/annotation-processors/#comment-form-load-service:Twitter" id="postas-twitter" title="Twitter">
					<span></span>
				</a>
			</li>
			<li>
				<a href="http://deors.wordpress.com/2011/10/08/annotation-processors/#comment-form-load-service:Facebook" id="postas-facebook" title="Facebook">
					<span></span>
				</a>
			</li>
		</ul>
	</div>

	<div id="comment-form-guest" class="comment-form-service selected">
		<div class="comment-form-padder">
			<div class="comment-form-avatar">
<a href="https://gravatar.com/site/signup/" target="_blank">				<img src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/ad516503a11cd5ca435acc9bb6523536" alt="Gravatar" width="25" class="no-grav">
</a>			</div>

				<div class="comment-form-fields">
				<div class="comment-form-field comment-form-email">
					<label for="email">Email <span class="required">(required)</span> <span class="nopublish">(Address never made public)</span></label>
					<div class="comment-form-input"><input id="email" name="email" type="email" value=""></div>
				</div>
				<div class="comment-form-field comment-form-author">
					<label for="author">Name <span class="required">(required)</span></label>
					<div class="comment-form-input"><input id="author" name="author" type="text" value=""></div>
				</div>
				<div class="comment-form-field comment-form-url">
					<label for="url">Website</label>
					<div class="comment-form-input"><input id="url" name="url" type="text" value=""></div>
				</div> 
			</div>
	
		</div>
	</div>

	<div id="comment-form-wordpress" class="comment-form-service">
		<div class="comment-form-padder">
			<div class="comment-form-avatar">
				<img src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/wplogo.png" alt="WordPress.com Logo" width="25" class="no-grav">
			</div>

				<div class="comment-form-fields">
				<input type="hidden" name="wp_avatar" id="wordpress-avatar" class="comment-meta-wordpress" value="">
				<input type="hidden" name="wp_user_id" id="wordpress-user_id" class="comment-meta-wordpress" value="">
				<input type="hidden" name="wp_access_token" id="wordpress-access_token" class="comment-meta-wordpress" value="">
				<p class="comment-form-posting-as pa-wordpress"><strong></strong> You are commenting using your WordPress.com account. <span class="comment-form-log-out">(&nbsp;<a href="javascript:HighlanderComments.doExternalLogout( 'wordpress' );">Log&nbsp;Out</a>&nbsp;/&nbsp;<a href="http://deors.wordpress.com/2011/10/08/annotation-processors/#" onclick="javascript:HighlanderComments.switchAccount();return false;">Change</a>&nbsp;)</span></p>
			</div>
	
		</div>
	</div>

	<div id="comment-form-twitter" class="comment-form-service">
		<div class="comment-form-padder">
			<div class="comment-form-avatar">
				<img src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/ad516503a11cd5ca435acc9bb6523536" alt="Twitter picture" width="25" class="no-grav">
			</div>

				<div class="comment-form-fields">
				<input type="hidden" name="twitter_avatar" id="twitter-avatar" class="comment-meta-twitter" value="">
				<input type="hidden" name="twitter_user_id" id="twitter-user_id" class="comment-meta-twitter" value="">
				<input type="hidden" name="twitter_access_token" id="twitter-access_token" class="comment-meta-twitter" value="">
				<p class="comment-form-posting-as pa-twitter"><strong></strong> You are commenting using your Twitter account. <span class="comment-form-log-out">(&nbsp;<a href="javascript:HighlanderComments.doExternalLogout( 'twitter' );">Log&nbsp;Out</a>&nbsp;/&nbsp;<a href="http://deors.wordpress.com/2011/10/08/annotation-processors/#" onclick="javascript:HighlanderComments.switchAccount();return false;">Change</a>&nbsp;)</span></p>
			</div>
	
		</div>
	</div>

	<div id="comment-form-facebook" class="comment-form-service">
		<div class="comment-form-padder">
			<div class="comment-form-avatar">
				<img src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/ad516503a11cd5ca435acc9bb6523536" alt="Facebook photo" width="25" class="no-grav">
			</div>

				<div class="comment-form-fields">
				<input type="hidden" name="fb_avatar" id="facebook-avatar" class="comment-meta-facebook" value="">
				<input type="hidden" name="fb_user_id" id="facebook-user_id" class="comment-meta-facebook" value="">
				<input type="hidden" name="fb_access_token" id="facebook-access_token" class="comment-meta-facebook" value="">
				<p class="comment-form-posting-as pa-facebook"><strong></strong> You are commenting using your Facebook account. <span class="comment-form-log-out">(&nbsp;<a href="javascript:HighlanderComments.doExternalLogout( 'facebook' );">Log&nbsp;Out</a>&nbsp;/&nbsp;<a href="http://deors.wordpress.com/2011/10/08/annotation-processors/#" onclick="javascript:HighlanderComments.switchAccount();return false;">Change</a>&nbsp;)</span></p>
			</div>
	
		</div>
	</div>


	<div id="comment-form-load-service" class="comment-form-service">
		<div class="comment-form-posting-as-cancel"><a href="javascript:HighlanderComments.cancelExternalWindow();">Cancel</a></div>
		<p>Connecting to %s</p>
	</div>
	
	
</div>

<script type="text/javascript">
jQuery(document).ready(function(){
	var input = document.createElement( 'input' ),
	    comment = jQuery( '#comment' );

	if ( 'placeholder' in input ) {
		comment.attr( 'placeholder', jQuery( '.comment-textarea label' ).remove().text() );
	}

	// Expando Mode: start small, then auto-resize on first click + text length
	jQuery( '#comment-form-identity' ).hide();
	jQuery( '#comment-form-subscribe' ).hide();
	jQuery( '#commentform .form-submit' ).hide();

	comment.css( { 'height':'10px' } ).one( 'focus', function() {
		var timer = setInterval( HighlanderComments.resizeCallback, 10 )
		jQuery( this ).animate( { 'height': HighlanderComments.initialHeight } ).delay( 100 ).queue( function(n) { clearInterval( timer ); HighlanderComments.resizeCallback(); n(); } );
		jQuery( '#comment-form-identity' ).slideDown();
		jQuery( '#comment-form-subscribe' ).slideDown();
		jQuery( '#commentform .form-submit' ).slideDown();
	});
});
</script>

<div id="comment-form-subscribe" style="display: none;"> 
	<p class="comment-subscription-form"><input type="checkbox" name="subscribe" id="subscribe" value="subscribe" style="width: auto;" tabindex="6"> <label class="subscribe-label" id="subscribe-label" for="subscribe">Notify me of follow-up comments via email.</label></p></div>

												<p class="form-submit" style="display: none;">
							<input name="submit" type="submit" id="comment-submit" value="Post Comment">
							<input type="hidden" name="comment_post_ID" value="85" id="comment_post_ID">
<input type="hidden" name="comment_parent" id="comment_parent" value="0">
						</p>
						
<input type="hidden" name="genseq" value="1352374395">
<p style="display: none;"><input type="hidden" id="akismet_comment_nonce" name="akismet_comment_nonce" value="946865d743"></p><script type="text/javascript" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/form.js"></script>
<p style="display: none;"><input type="hidden" id="ak_js" name="ak_js" value="1352374395985"></p>					</form>
							</div><!-- #respond -->
			<div style="clear: both"></div>			
</div><!-- #comments -->

				
			</div><!-- #content -->
		</div><!-- #primary -->


	</div><!-- #main -->

	<footer id="colophon" role="contentinfo">

			

			<div id="site-generator">
				Theme: <a href="http://theme.wordpress.com/themes/twentyeleven/" title="Learn more about this theme">Twenty Eleven</a> <span class="sep"> | </span>				<a href="http://wordpress.com/?ref=footer" rel="generator">Blog at WordPress.com</a>.
			</div>
	</footer><!-- #colophon -->
</div><!-- #page -->


<script type="text/javascript">
var _qevents = _qevents || [], wpcomQuantcastData = {"qacct":"p-18-mFEk4J448M","labels":",language.en,type.wpcom,posttag.annotation-processors,posttag.annotations,posttag.eclipse,posttag.maven,as"};
function wpcomQuantcastPixel( labels, options ) {
	var i, defaults = wpcomQuantcastData, data = { event: 'ajax' };

	labels  = labels  || '';
	options = options || {};

	if ( typeof labels != 'string' )
		options = labels;

	for ( i in defaults ) {
		data[i] = defaults[i];
	}

	for ( i in options ) {
		data[i] = options[i];
	}

	if ( data.labels ) {
		data.labels += ',' + labels;
	} else {
		data.labels = labels;
	}

	_qevents.push( data );
};
(function() {var elem = document.createElement('script');elem.src = (document.location.protocol == "https:" ? "https://secure" : "http://edge") + ".quantserve.com/quant.js";elem.async = true;elem.type = "text/javascript";var scpt = document.getElementsByTagName('script')[0];scpt.parentNode.insertBefore(elem, scpt);  })();
_qevents.push( wpcomQuantcastData );
</script>
<noscript>&lt;div style="display: none;"&gt;&lt;img src="//pixel.quantserve.com/pixel/p-18-mFEk4J448M.gif?labels=%2Clanguage.en%2Ctype.wpcom%2Cposttag.annotation-processors%2Cposttag.annotations%2Cposttag.eclipse%2Cposttag.maven%2Cas" height="1" width="1" alt="" /&gt;&lt;/div&gt;</noscript>


	<script type="text/javascript">
	/* <![CDATA[ */
	(function($){
		$(document).on( 'ready post-load', function() {

			// Remove the login box when clicking the page
			$( document ).mousedown( function( e ) {
				if ( null == $( e.target ).closest( '#wpl-mustlogin' ).get( 0 ) ) {
					$( '#wpl-mustlogin' ).remove();
				}
			});

			// Handle clicking the like button itself
			$('.wpl-button > a.like').click( function(e) {
				e.preventDefault();

				var postid = $(this).parent().attr('id').split('like-')[1];
				$.post( 'http://deors.wordpress.com/wp-admin/admin-ajax.php', {
					'action': 'wpl_record_stat',
					'stat_name': 'loggedout_like_click'
				} );

				var tenMins = new Date();
				tenMins.setTime( tenMins.getTime() + 600000 );
				document.cookie = 'wpl_rand=c895838bc1; expires=' + tenMins.toGMTString() + '; domain=wordpress.com; path=/;';

				$(this).parent().siblings('.wpl-count').after( '\
					<div id="wpl-mustlogin"> \
						<form action="https://deors.wordpress.com/wp-login.php" method="post"> \
							<p>Just one more step to like this:</p> \
							<label><span>Username</span> <input type="text" name="log" id="user_login" class="input" value="" size="20" tabindex="80" /></label> \
							<label><span>Password</span> <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="81" /></label> \
							<input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="Log In" tabindex="82" /> \
							<input type="hidden" name="postid" value="' + postid + '" /> \
							<input type="hidden" name="redirect_to" value="http://deors.wordpress.com/2011/10/08/annotation-processors?year=2011&#038;monthnum=10&#038;day=08&#038;name=annotation-processors&#038;like=1" /> \
							<input type="hidden" name="wpl_rand" value="c895838bc1" /> \
							<p>Not a member yet? <a href="http://wordpress.com/signup/?ref=likebox&user=1" id="wpl-signup-link">Sign up with WordPress.com for free</a></p> \
						</form> \
					</div> \
				');

				$('#wpl-mustlogin').hide().slideDown('fast');
			} );

			$('#wpl-mustlogin input.input').live( 'focus', function() {
				$(this).prev().hide();
			}).live( 'blur', function() {
				if ( $(this).val() == '' ) {
					$(this).prev().show();
				}
			});

			$('#wpl-mustlogin input#wp-submit').live( 'click', function(e) {
				e.preventDefault();

				$.post( 'http://deors.wordpress.com/wp-admin/admin-ajax.php', {
					'action': 'wpl_record_stat',
					'stat_name': 'loggedout_login_submit'
				}, function() {
					$('#wpl-mustlogin form').submit();
				} );
			});

			$('#wpl-mustlogin a#wpl-signup-link').live( 'click', function(e) {
				e.preventDefault();

				var link = $(this).attr('href');

				$.post( 'http://deors.wordpress.com/wp-admin/admin-ajax.php', {
					'action': 'wpl_record_stat',
					'stat_name': 'loggedout_signup_click'
				}, function() {
					location.href = link;
				} );
			});
		})
	})(jQuery);
	/* ]]> */
	</script>
<script type="text/javascript" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/gprofiles.js"></script>
<script type="text/javascript">
/* <![CDATA[ */
var WPGroHo = {"my_hash":""};
/* ]]> */
</script>
<script type="text/javascript" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/wpgroho.js"></script>
<script>jQuery(document).ready(function($){ Gravatar.profile_cb = function( h, d ) { WPGroHo.syncProfileData( h, d );	}; Gravatar.my_hash = WPGroHo.my_hash; Gravatar.init( 'body', '#wp-admin-bar-my-account' ); });</script>	<div style="display:none">
	<div class="grofile-hash-map-e0a9e6bbe2424900880e24e19dab9a7f">
	</div>
	</div>
<script type="text/javascript">
/* <![CDATA[ */
var HighlanderComments = {"loggingInText":"Logging In\u2026","submittingText":"Posting Comment\u2026","postCommentText":"Post Comment","connectingToText":"Connecting to %s","commentingAsText":"%1$s: You are commenting using your %2$s account.","logoutText":"Log Out","loginText":"Log In","connectURL":"http:\/\/deors.wordpress.com\/public.api\/connect\/?action=request","logoutURL":"http:\/\/deors.wordpress.com\/wp-login.php?action=logout&_wpnonce=ebc03a0bef","homeURL":"http:\/\/deors.wordpress.com\/","postID":"85","gravDefault":"identicon","enterACommentError":"Please enter a comment","enterEmailError":"Please enter your email address here","invalidEmailError":"Invalid email address","enterAuthorError":"Please enter your name here","gravatarFromEmail":"This picture will show whenever you leave a comment. Click to customize it.","logInToExternalAccount":"Log in to use details from one of these accounts.","change":"Change","changeAccount":"Change Account","comment_registration":"0","userIsLoggedIn":"","isJetpack":"0"};
/* ]]> */
</script>
<script type="text/javascript" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/script.js"></script>

	<div id="bit" class="loggedout-follow-normal" style="bottom: -280px;">
		<a class="bsub" href="javascript:void(0)"><span id="bsub-text">Follow</span></a>
		<div id="bitsubscribe">

					<h3><label for="loggedout-follow-field">Follow “dr. macphail's trance”</label></h3>

			<form action="https://subscribe.wordpress.com/" method="post" accept-charset="utf-8" id="loggedout-follow">
			<p>Get every new post delivered to your Inbox.</p>

			<p id="loggedout-follow-error" style="display: none;"></p>

						<p class="bit-follow-count">Join 25 other followers</p>
			<p><input type="email" name="email" style="width: 95%; padding: 1px 2px" value="Enter your email address" onfocus="this.value=(this.value==&quot;Enter your email address&quot;) ? &quot;&quot; : this.value;" onblur="this.value=(this.value==&quot;&quot;) ? &quot;Enter email address&quot; : this.value;" id="loggedout-follow-field"></p>

			<input type="hidden" name="action" value="subscribe">
			<input type="hidden" name="blog_id" value="21758442">
			<input type="hidden" name="source" value="http://deors.wordpress.com/2011/10/08/annotation-processors/">
			<input type="hidden" name="sub-type" value="loggedout-follow">

			<input type="hidden" id="_wpnonce" name="_wpnonce" value="4b2c94c399"><input type="hidden" name="_wp_http_referer" value="/2011/10/08/annotation-processors/">
			<p id="bsub-subscribe-button"><input type="submit" value="Sign me up"></p>
			</form>
					<div id="bsub-credit"><a href="http://wordpress.com/signup/?ref=lof">Powered by WordPress.com</a></div>
		</div><!-- #bitsubscribe -->
	</div><!-- #bit -->
<script type="text/javascript" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/beacon.js"></script><script type="text/javascript">try{COMSCORE.beacon({c1:2,c2:7518284});}catch(e){}</script><noscript>&lt;p class="robots-nocontent"&gt;&lt;img src="http://b.scorecardresearch.com/p?cj=1c1=2&amp;#038;c2=7518284" alt="" style="display:none" width="1" height="1" /&gt;&lt;/p&gt;</noscript><script type="text/javascript">
/* <![CDATA[ */
var thickboxL10n = {"next":"Next >","prev":"< Prev","image":"Image","of":"of","close":"Close","noiframes":"This feature requires inline frames. You have iframes disabled or your browser does not support them.","loadingAnimation":"http:\/\/deors.wordpress.com\/wp-includes\/js\/thickbox\/loadingAnimation.gif","closeImage":"http:\/\/deors.wordpress.com\/wp-includes\/js\/thickbox\/tb-close.png"};
var thickboxL10n = {"next":"Next >","prev":"< Prev","image":"Image","of":"of","close":"Close","noiframes":"This feature requires inline frames. You have iframes disabled or your browser does not support them.","loadingAnimation":"http:\/\/deors.wordpress.com\/wp-includes\/js\/thickbox\/loadingAnimation.gif","closeImage":"http:\/\/deors.wordpress.com\/wp-includes\/js\/thickbox\/tb-close.png"};
/* ]]> */
</script>
<script type="text/javascript" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/saved_resource(2)"></script>
<script type="text/javascript">
// <![CDATA[
(function() {
try{
  if ( window.external &&'msIsSiteMode' in window.external) {
    if (window.external.msIsSiteMode()) {
      var jl = document.createElement('script');
      jl.type='text/javascript';
      jl.async=true;
      jl.src='/wp-content/plugins/ie-sitemode/custom-jumplist.php';
      var s = document.getElementsByTagName('script')[0];
      s.parentNode.insertBefore(jl, s);
    }
  }
}catch(e){}
})();
// ]]>
</script><script src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/w.js" type="text/javascript"></script>
<script type="text/javascript">
st_go({'blog':'21758442','v':'wpcom','user_id':'0','post':'85','subd':'deors'});
ex_go({'crypt':'UE5XaGUuOTlwaD85flAmcm1mcmZsaDhkV11YdTdvUG14Q2VDQTR4LlUsLi82dU1mai9BMk4lKyUuTUZJLVp5cWs3M2QveDhkJXxRcz1nQlRHUXRxOTZrLm13TDB4dUlrJmF6bVIlLFFCPUJwS09qJWslZ0YuSCZtL1glbFtXZ29vLlk/T2tFSVlNeWNmQTZbaGxMaTJTM3EwRVZ5dXVKX2lyUkhBMjYxSFFzYmt5LHo2Mz1BOU1KQSZySU12Tz8vSndIWGlVY08yUEZRbi1PeWlic0NhU1lnYWRbX2oxZG91W01KOVR1dUs5clR3Q3A5MjVxUGFBTXRZdWk9N0xkM2xNdiU1RF1+LHIxYmUyflkmVF1oLTNqN0M0OVh0UGpyUUhTQzIweUg5UUlbalE0Kw=='});
addLoadEvent(function(){linktracker_init('21758442',85);});
	</script><img id="wpstats" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/g.gif" alt=""><img id="wpstats2" src="./Code Generation using Annotation Processors in the Java language – part 2  Annotation Processors   dr. macphail's trance_files/g(1).gif" alt="" style="display:none">
<noscript>&lt;img src="http://stats.wordpress.com/b.gif?v=noscript" style="height:0px;width:0px;overflow:hidden" alt="" /&gt;</noscript>


</body></html>